#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int maxn=100050;
int d[maxn],v[maxn],a[maxn],p[maxn];
signed main()
{
    ios::sync_with_stdio();cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while (T--)
    {
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        for (int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
        int maxx=0;
        for (int i=1;i<=m;i++)
        {
            cin>>p[i];
            if (p[i]>maxx)maxx=p[i];
        }
        int cnt=0;
        for(int i=1;i<=n;i++)if (v[i]>V&&d[i]<=maxx)cnt++;
        cout<<cnt<<" ";
        if (cnt)cout<<(m-1)<<endl;
        else cout<<m<<endl;
    }
    return 0;
}
